package com.decent.common.entity.manager;

import com.decent.common.constant.DatePatternConstant;
import com.decent.common.enums.CommonStatusEnum;
import com.decent.common.enums.manager.UserTypeEnum;
import com.decent.common.validator.operate.Add;
import com.decent.common.validator.operate.Update;
import com.decent.common.validator.operate.UpdateStatus;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 系统用户
 *
 * @author wangyan
 **/
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder(toBuilder = true)
@Data
public class SystemUser implements Serializable {
    private static final long serialVersionUID = -6479932954495522985L;
    /**
     * 主键
     */
    private Long id;

    /**
     * 账号
     */
    @NotBlank(message = "账号不能为空", groups = {Add.class, Update.class})
    @Length(max = 30, message = "请输入30字内的账号", groups = {Add.class, Update.class})
    private String userAccount;

    /**
     * 密码
     */
    private String loginPassword;

    /**
     * 姓名
     */
    @NotBlank(message = "用户名不能为空", groups = {Add.class})
    @Length(max = 4, message = "请输入4字内的姓名", groups = {Add.class, Update.class})
    private String userName;

    /**
     * 手机号
     */
    @NotBlank(message = "手机号不能为空", groups = {Add.class})
    @Length(max = 15, message = "请输入有效的手机号", groups = {Add.class, Update.class})
    private String mobile;

    /**
     * 最后登陆IP
     */
    private String lastLoginIp;

    /**
     * 最后登陆时间
     */
    @JsonFormat(pattern = DatePatternConstant.NORM_DATETIME_PATTERN)
    private LocalDateTime lastLoginTime;

    /**
     * 会员类型
     */
    private UserTypeEnum userType;

    /**
     * 状态
     */
    @NotNull(message = "状态不能为空", groups = {UpdateStatus.class})
    private CommonStatusEnum userStatus;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = DatePatternConstant.NORM_DATETIME_PATTERN, timezone = DatePatternConstant.TIMEZONE)
    private LocalDateTime createTime;

    /**
     * 备注
     */
    private String remark;

    /**
     * 创建人
     */
    private String creator;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = DatePatternConstant.NORM_DATETIME_PATTERN, timezone = DatePatternConstant.TIMEZONE)
    private LocalDateTime updateTime;

    /**
     * 更新人
     */
    private String lastModifier;
}
